#include "smallwidget.h"
#include "ui_smallwidget.h"

smallwidget::smallwidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::smallwidget)
{
    ui->setupUi(this);

    //qspinbox改变，qslider跟着移动
    void(QSpinBox:: * spsignal)(int) = &QSpinBox::valueChanged ;//函数指针
    connect(ui->spinBox , spsignal , ui->horizontalSlider , &QSlider::setValue);

    //qslider滑动，qspinbox跟着改变
    connect(ui->horizontalSlider, &QSlider::valueChanged , ui->spinBox , &QSpinBox::setValue);
}

void smallwidget::setnum(int num)
{
    ui->spinBox->setValue(num);
}

int smallwidget::getnum()
{
    return ui->spinBox->value();
}

smallwidget::~smallwidget()
{
    delete ui;
}


